package com.kimari.factory.simple;

/**
 * 车子工厂
 *
 * @author Reimu
 */
public class CarFactory {
    private static final String TESLA = "特斯拉";
    private static final String BENZ = "奔驰";

    public static Car getCar(String car) {
        if (TESLA.equalsIgnoreCase(car)) {
            return new Tesla();
        } else if (BENZ.equalsIgnoreCase(car)) {
            return new Benz();
        }
        return null;
    }

    public static void main(String[] args) {
        Car car1 = CarFactory.getCar(CarFactory.BENZ);
        Car car2 = CarFactory.getCar(CarFactory.TESLA);

        assert car1 != null;
        car1.name();
        assert car2 != null;
        car2.name();
    }
}
